# $Id: PKGBUILD 86825 2013-03-22 13:22:11Z alucryd $
# Maintainer: Maxime Gauduin <alucryd@gmail.com>
# Contributor: trya <tryagainprod@gmail.com>
# Contributor: robb_force <robb_force@holybuffalo.net>

pkgname=gens
pkgver=2.15.5
pkgrel=8
pkgdesc='A Sega Genesis / Sega CD / Sega 32X emulator'
arch=('i686' 'x86_64')
url='http://gens.sourceforge.net'
license=('GPL')
if [[ $CARCH == "x86_64" ]]; then
  makedepends=('gcc-multilib' 'lib32-gtk2' 'lib32-mesa-libgl' 'lib32-sdl' 'nasm')
  optdepends=('lib32-alsa-plugins: Sound support for PulseAudio'
              'lib32-libpulse: Sound support for PulseAudio')
else
  depends=('gtk2' 'sdl')
  makedepends=('nasm')
fi
options=('!buildflags')
source=("http://downloads.sourceforge.net/${pkgname}/${pkgname}-${pkgver}.tar.gz"
        'gens.desktop')
sha256sums=('51910d3056da9ffbb2c01cfec064998c9a4cad0cb379d703ec1b93c83dba305a'
            '146a0e98780b909877b3937c9132c85f5aba9450ef9f748bd1374ae8c9dfb751')

build() {
  cd "${srcdir}"/${pkgname}-${pkgver}

# Multilib
  if [[ $CARCH == "x86_64" ]]; then
    export CC="gcc -m32"
    export CXX="g++ -m32"
    export PKG_CONFIG_PATH="/usr/lib32/pkgconfig"
  fi

# Build
  export LDFLAGS=-Wl,-z,noexecstack
  ./configure --host=i686-unknown-linux-gnu --prefix=/usr
  make
}

package() {
  cd "${srcdir}"/${pkgname}-${pkgver}

# Multilib
  if [[ $CARCH == "x86_64" ]]; then
    depends=('lib32-gtk2' 'lib32-sdl')
  fi

# Install
  make DESTDIR=${pkgdir} install
  install -dm 755 "${pkgdir}"/usr/share/applications
  install -m 644 ../gens.desktop "${pkgdir}"/usr/share/applications/gens.desktop
}

# vim: ts=2 sw=2 et:
